package newXgame.hall.net
{
	import anshe.event.AnsheNetEvent;
	import anshe.net.RedConnection;
	
	import flash.events.EventDispatcher;
	
	import newXgame.hall.globals.Globals;
	
	public class HallNetManage extends EventDispatcher
	{
		private var gObj:Globals;
		private var ncHall:RedConnection;		//	大厅专用的 NC 对象
		
		public function HallNetManage()
		{
			gObj = Globals.getObject();			
			ncHall = gObj.ncHall;
		}
		
		public function LinkNC():void
		{
			ncHall.addEventListener(AnsheNetEvent.SERVER_CONN_COMPLETE, onConnComplete);
			ncHall.addEventListener(AnsheNetEvent.SERVER_CONN_ERROR, onConnError);
			ncHall.addEventListener(AnsheNetEvent.SERVER_CLOSE, onServerClose);
			ncHall.connect(gObj.serverPath);
		}
		
		private function onConnComplete(e:AnsheNetEvent):void
		{
			ncHall.client = this;
		}
		
		private function onConnError(e:AnsheNetEvent):void
		{
			this.dispatchEvent(e);
		}
		
		private function onServerClose(e:AnsheNetEvent):void
		{
			this.dispatchEvent(e);
		}		
	}
}